﻿using Abp.Domain.Repositories;
using AppFramework.DinosaursParkMes.TicketTask.DTO;
using Microsoft.AspNetCore.Mvc;
using Stripe;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AppFramework.DinosaursParkMes.TicketTask
{
    /// <summary>
    /// 班组管理
    /// </summary>
    public class TeamorGroupinfoAppService : AppFrameworkAppServiceBase, ITeamorGroupinfoAppService
    {
        private readonly IRepository<TeamorGroupinfo> repository;

        public TeamorGroupinfoAppService(IRepository<TeamorGroupinfo> repository)
        {
            this.repository = repository;
        }
        /// <summary>
        /// 班组反填（获取负责人）
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet,Route("SelectTeamorGroup")]
        public async Task<dynamic> SelectTeamorGroup(int id)
        {
            var list = from a in repository.GetAll() where a.Id == id select a.Principal;
            return list.FirstOrDefault();
        }
        /// <summary>
        /// 班组列表
        /// </summary>
        /// <returns></returns>
        [HttpGet, Route("TeamorGroupList")]
        public async Task<List<TeamorGroupResponseDTO>> TeamorGroupList()
        {
            var list = from a in repository.GetAll()
                       select new TeamorGroupResponseDTO
                       {
                           Id= a.Id,
                           Classencoding= a.Classencoding,
                           Classname= a.Classname,
                           Classtype= a.Classtype,
                           IsDeleted= a.IsDeleted,
                           Number= a.Number,
                           Principal= a.Principal,
                       };
            return list.ToList();
        }
    }
}
